﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPFUIControl
{
    /// <summary>
    /// NavigationMenu.xaml 的交互逻辑
    /// </summary>
    public partial class NavigationMenu : Window
    {
        public NavigationMenu()
        {
            InitializeComponent();
            ObservableCollection<MenuItem> menuList = new ObservableCollection<MenuItem>();
            MenuItem menu1 = new MenuItem() { Title = "主菜单1" };
            ObservableCollection<MenuItem> submenuList1 = new ObservableCollection<MenuItem>();
            submenuList1.Add(new MenuItem { Title = "主菜单1-子菜单1" });
            submenuList1.Add(new MenuItem { Title = "主菜单1-子菜单2" });
            submenuList1.Add(new MenuItem { Title = "主菜单1-子菜单3" });

            MenuItem menu2 = new MenuItem() { Title = "主菜单2" };
            ObservableCollection<MenuItem> submenuList2 = new ObservableCollection<MenuItem>();
            submenuList2.Add(new MenuItem { Title = "主菜单2-子菜单1" });
            submenuList2.Add(new MenuItem { Title = "主菜单2-子菜单2" });
            submenuList2.Add(new MenuItem { Title = "主菜单2-子菜单3" });

            MenuItem menu3 = new MenuItem() { Title = "主菜单3" };
            menu1.SubMenuItem = submenuList1;
            menu2.SubMenuItem = submenuList2;
            menuList.Add(menu1);
            menuList.Add(menu2);
            menuList.Add(menu3);
            this.DataContext = new ViewModel() { MenuList = menuList };
        }
    }
}
